package objexc;

public class GirlFriendTest {
    public static void main(String[] args) {
        //创建数组
        GirlFriend[] arr = new GirlFriend[4];
        //创建对象
        GirlFriend g1 = new GirlFriend("小李",18,"女","阅读");
        GirlFriend g2 = new GirlFriend("小王",20,"女","零食");
        GirlFriend g3 = new GirlFriend("小张",21,"女","手机");
        GirlFriend g4 = new GirlFriend("小陈",19,"女","追剧");
        //把对象添加数组
        arr[0] = g1;
        arr[1] = g2;
        arr[2] = g3;
        arr[3] = g4;
        //求和
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            GirlFriend gf = arr[i];
            sum+=gf.getAge();
        }
        int avg = sum/arr.length;
        System.out.println(avg);
        int count=0;
        for (int i = 0; i < arr.length; i++) {
            GirlFriend gf = arr[i];
            if(gf.getAge() < avg){
                count++;
                System.out.println(gf.getName() + ", " + gf.getAge() + ", " + gf.getGender() + ", " + gf.getHobby());
            }
        }
        System.out.println(count);
    }
}
